<!DOCTYPE html>
<html class="no-js" lang="zxx" xmlns:th="http://www.thymeleaf.org">
<body>
<header th:fragment="header" th:object="${user}">
    <div class="header-area header-transparent" style="background-color: rgba(255,255,255,0.8)">
        <div class="main-header header-sticky">
            <div class="container">
                <div class="menu-wrapper d-flex align-items-center justify-content-between">
                    <div class="left-content d-flex align-items-center">
                        <div class="logo mr-45">
                            <a href="index"><img src="http://localhost:8080/assets/img/logo/logo.png" alt=""></a>
                        </div>
                        <!-- Main-menu -->
                        <div class="main-menu d-none d-lg-block">
                            <nav th:if="${user!=null}">
                                <ul id="navigation">
                                    <li><a href="index">主页</a></li>
                                    <li><a href="houses">浏览房屋</a></li>
                                    <li th:if="${user.getRole().equals('admin')}"><a href="user">浏览用户</a></li>
                                    <li th:if="${!user.getRole().equals('admin')}"><a href="personal-house">个人房屋</a>
                                    </li>
                                    <li th:if="${!user.getRole().equals('admin')}"><a
                                            href="rented-house">租用房屋</a></li>
                                    <li><a th:href="'personal-info?id=' + ${user.getId()}">个人信息</a></li>
                                    <li><a href="advice">建议</a></li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                    <!-- Button -->
                    <div class="buttons">
                        <ul>
                            <li class="button-header">
                                <a th:unless="${user}" href="login" class="btn header-btn2">登录</a>
                                <a th:if="${user}" class="header-btn2x"
                                   th:text="${user.getRole().equals('admin') ? '管理员' : '用户'}"></a>
                                <a style="cursor: pointer" onclick="showSlickInfo()" th:if="${user}">
                                    <img src="http://localhost:8080/assets/img/gallery/1.png"
                                         style="width: 50px;height: 50px;" alt="">
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="slick-user-info" class="slick-slidex" style="display: none">
        <a href="personal-info" class="btn header-btn2">个人信息</a>
        <a th:if="${user}" href="logout" class="btn header-btn2xx">退出</a>
    </div>
    <script type="text/javascript">
        let slickInfo = document.getElementById('slick-user-info')

        function showSlickInfo() {
            var display = slickInfo.style.display;
            if (display !== '') {
                slickInfo.style.display = ''
                slickInfo.style.top = '120px'
            } else {
                slickInfo.style.display = 'none'
            }
            for (let i = 0; i < 40; i++)
                setTimeout(() => {
                    slickInfo.style.top = '' + (120 - i - 1) + 'px'
                }, (i + 1) * 3)
        }

        window.addEventListener('mousewheel', () => {
            slickInfo.style.display = 'none'
        })
    </script>
</header>
<footer th:fragment="footer"></footer>
</body>
</html>